Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assertion when attempting to convert f16 and f128 with as #125172

Merged
merged 1 commit into from
May 16, 2024

Conversation

tgross35
Copy link
Contributor

These types are currently rejected for as casts by the compiler. Remove this incorrect check and add codegen tests for all conversions involving these types.

These types are currently rejected for `as` casts by the compiler.
Remove this incorrect check and add codegen tests for all conversions
involving these types.
@rustbot
Copy link
Collaborator

rustbot commented May 16, 2024

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 16, 2024
@tgross35
Copy link
Contributor Author

Sample crash:

#![feature(f128)]

fn foo(a: f128) -> u32 { a as u32 }

fn main() {
    dbg!(foo(1.0));
}
thread 'rustc' panicked at /rustc/1871252fc8bb672d40787e67404e6eaae7059369/compiler/rustc_codegen_ssa/src/traits/builder.rs:250:9:
assertion failed: matches!(self.cx().type_kind(float_ty), TypeKind::Float | TypeKind::Double)
stack backtrace:
...
  18:     0x7f5f401c420c - core::panicking::panic::hb6a980c1ddfde273
                               at /rustc/1871252fc8bb672d40787e67404e6eaae7059369/library/core/src/panicking.rs:146:5
  19:     0x7f5f45dd5c99 - <rustc_codegen_llvm[620bcbc10f362457]::builder::Builder as rustc_codegen_ssa[1359b97849c8d67a]::traits::builder::BuilderMethods>::cast_float_to_int.cold
  20:     0x7f5f44a5749f - <rustc_codegen_ssa[1359b97849c8d67a]::mir::FunctionCx<rustc_codegen_llvm[620bcbc10f362457]::builder::Builder>>::codegen_rvalue_operand
  21:     0x7f5f45301b6d - rustc_codegen_ssa[1359b97849c8d67a]::mir::codegen_mir::<rustc_codegen_llvm[620bcbc10f362457]::builder::Builder>
  22:     0x7f5f452ec8fb - rustc_codegen_llvm[620bcbc10f362457]::base::compile_codegen_unit::module_codegen
  23:     0x7f5f452e8bd6 - <rustc_codegen_llvm[620bcbc10f362457]::LlvmCodegenBackend as rustc_codegen_ssa[1359b97849c8d67a]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  24:     0x7f5f455949dd - rustc_codegen_ssa[1359b97849c8d67a]::base::codegen_crate::<rustc_codegen_llvm[620bcbc10f362457]::LlvmCodegenBackend>
  25:     0x7f5f453ee4cc - <rustc_codegen_llvm[620bcbc10f362457]::LlvmCodegenBackend as rustc_codegen_ssa[1359b97849c8d67a]::traits::backend::CodegenBackend>::codegen_crate
  26:     0x7f5f453ede5f - rustc_interface[7b2cde0250eb35bd]::passes::start_codegen
  27:     0x7f5f453ed4da - <rustc_interface[7b2cde0250eb35bd]::queries::Queries>::codegen_and_build_linker
  28:     0x7f5f452439ae - rustc_interface[7b2cde0250eb35bd]::interface::run_compiler::<core[2d1e9e5bb9922d42]::result::Result<(), rustc_span[fd1022c3f6e6087e]::ErrorGuaranteed>, rustc_driver_impl[146ec381f5ba6798]::run_compiler::{closure#0}>::{closure#1}
...

@tgross35
Copy link
Contributor Author

@rustbot label +F-f16_and_f128

@rustbot rustbot added the F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` label May 16, 2024
@compiler-errors
Copy link
Member

r? compiler-errors @bors r+ rollup

@bors
Copy link
Contributor

bors commented May 16, 2024

📌 Commit 488ddd3 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 16, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#124871 (Don't ICE because recomputing overflow goals during find_best_leaf_obligation causes inference side-effects)
 - rust-lang#125018 (Update linker-plugin-lto.md to include LLVM 18)
 - rust-lang#125130 (rustdoc-json-types: Document `Id`)
 - rust-lang#125170 (Uplift `FnSig` into `rustc_type_ir` (redux))
 - rust-lang#125172 (Fix assertion when attempting to convert `f16` and `f128` with `as`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e3864db into rust-lang:master May 16, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 16, 2024
Rollup merge of rust-lang#125172 - tgross35:f16-f128-as-casting, r=compiler-errors

Fix assertion when attempting to convert `f16` and `f128` with `as`

These types are currently rejected for `as` casts by the compiler. Remove this incorrect check and add codegen tests for all conversions involving these types.
@rustbot rustbot added this to the 1.80.0 milestone May 16, 2024
@tgross35 tgross35 deleted the f16-f128-as-casting branch May 16, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants